<template>
  <div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      
    >
      <van-cell v-for="(item,index) in list" :key="index">
        <template #title>
          <sessionContent :sessionData="item"></sessionContent>
        </template>
      </van-cell>
    </van-list>
  </div>
</template>

<script>
import sessionContent from "@/components/sessionContent";
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
    };
  },
  props: {
    getData: Function,
  },
  components: {
    sessionContent,
  },
  methods: {
    async onLoad() {
      let data = await this.getData();
        
      this.list.push(...data);
     

      this.loading = false;
      // 数据到达20条时停止加载
      if (this.list.length >= 20) {
          
        this.finished = true;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.van-list{
    height: 500px;
    overflow-y: scroll;

}
</style>